Skip to content

[iOS] Mirror only horizontal ScrollViews in RTL, so the iOS 26 large title is not mirrored - #60020

Open
ArekChr wants to merge 2 commits into
react:mainfrom
ArekChr:fix-rtl-vertical-scrollview-mirror
Open

ArekChr wants to merge 2 commits into
react:mainfrom
ArekChr:fix-rtl-vertical-scrollview-mirror

Conversation

@ArekChr

@ArekChr ArekChr commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

In RTL, RCTScrollViewComponentView mirrors the UIScrollView and its content view (scaleX: -1 on both), so a horizontal scroll view starts at the right edge while its content still reads correctly.

It does this for every scroll view, vertical ones included. A vertical scroll view gains nothing from it, and the two flips cancel out only for the content view. Any view UIKit adds to the scroll view itself stays mirrored once. On iOS 26 the navigation bar's large title is such a view: with a native stack (headerLargeTitle: true) in an RTL app, the title shows up as a mirrored image at the left edge (screenshot below).

This change mirrors only a scroll view whose horizontal prop is true. The transform is recomputed when the props or the layout direction change, so a recycled view also picks up the right state.

Changelog:

[IOS] [FIXED] - In RTL, mirror only horizontal ScrollViews, so the iOS 26 large navigation title is no longer mirrored

[IOS] [CHANGED] - In RTL, a vertical ScrollView whose content is wider than the view now starts at the left edge

Test Plan:

Tested in a production app on React Native 0.88.1 with react-native-screens 4.30.1, on the iOS 26 simulator, with the app in Arabic (I18nManager.forceRTL(true)).

  • Large title in a native stack over a vertical ScrollView: before the change it was mirrored at the left edge. After the change it is right-aligned and reads correctly (screenshot).
  • Horizontal ScrollViews (a pill tab bar that scrolls the selected pill into view with scrollTo, a segmented row): they still start at the right edge, and scrollTo / onScroll offsets are unchanged.
  • Vertical lists (ScrollView, FlatList): their layout is unchanged.
  • XCTests: RCTScrollViewComponentViewRTLTests in RNTesterUnitTests covers a horizontal RTL view staying mirrored, a vertical RTL view not being mirrored and getting RTL semantics, scrollTo and the reported x round-tripping in both, and a recycled view whose horizontal or layout direction changed.
  • LTR (Polish): the same screens look the same before and after. In LTR the transform is the identity in both versions.

Before and after: the large title in an RTL native stack on iOS 26

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 16, 2026
In RTL, RCTScrollViewComponentView mirrored every scroll view. A vertical one
gains nothing from it, and UIKit's views added to the scroll view outside the
content view were left mirrored: on iOS 26 the navigation bar's large title is
one of them, so it showed up mirrored at the left edge.
@ArekChr
ArekChr force-pushed the fix-rtl-vertical-scrollview-mirror branch from 6eedd8c to e29461d Compare November 16, 2026 10:43
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 16, 2026

@Abbondanzo Abbondanzo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down. Dropping the transform for vertical scroll views is the right approach, but a few places still assume the view is mirrored, which causes three RTL regressions for vertical scroll views:

  1. scrollTo/onScroll x is mirrored when the content is wider than the view. The two RTL conversions still run for every RTL scroll view (see my inline comments below).
  2. The vertical scroll indicator moves from the left to the right and we should make sure this doesn't regress. In RTL, native iOS and Android both put it on the left, so we should ensure we do the same. The inner scroll view is forced to UISemanticContentAttributeForceLeftToRight, which was only correct while the whole view was mirrored. Also added an inline comment for this one
  3. Vertical scroll views with wider-than-viewport content now open at the RTL end instead of the RTL start. Before this change they started at the right edge, as horizontal scroll views still do, as Android's HorizontalScrollView does in RTL, and as Material's bidirectionality guidance describes for horizontally scrolling content.

The first two are easy to fix with the inline suggests, but the third needs some love. Could you either set the initial offset to the right edge for RTL vertical views that can scroll horizontally, or call out the change in the changelog?

Could you also add XCTest coverage for:

  • an RTL horizontal view stays mirrored;
  • an RTL vertical view isn't mirrored and gets RTL semantics;
  • scrollTo and the reported x round-trip correctly in both; and
  • a recycled view whose horizontal value changed?

If you want a repro for the third issue, here's what I used:

<ScrollView
  horizontal={false}
  style={{direction: 'rtl', width: 300, height: 60}}
  contentContainerStyle={{width: 900, height: 60}}
  onScroll={e => console.log(e.nativeEvent.contentOffset.x)}>
  {[0, 150, 300, 450, 600, 750].map(x => (
    <Text key={x} style={{position: 'absolute', left: x}}>{`|x=${x}`}</Text>
  ))}
</ScrollView>

With this PR, scrollTo({x: 0}) shows the x=600-900 labels while onScroll reports x=0. Before this PR, and in a horizontal scroll view, it shows x=0-300.

Comment on lines 318 to 327

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that vertical scroll views aren't mirrored, as you alluded to in your PR body, forcing UISemanticContentAttributeForceLeftToRight puts the vertical indicator on the right in RTL (native iOS and Android put it on the left). Giving the scroll view RTL semantics when it's RTL but not mirrored fixes that. A shared _isMirrored also lets the two x conversions below use the same condition:

The comment in RCTEnhancedScrollView's initWithFrame: should then say that left-to-right is the default and only stays forced while the view is mirrored.

Suggested change
- (BOOL)_isMirrored
{
const auto &scrollViewProps = static_cast<const ScrollViewProps &>(*_props);
return _layoutMetrics.layoutDirection == LayoutDirection::RightToLeft && scrollViewProps.horizontal;
}
- (void)_updateRightToLeftTransform
{
BOOL rtl = _layoutMetrics.layoutDirection == LayoutDirection::RightToLeft;
BOOL mirrored = [self _isMirrored];
CGAffineTransform transform = mirrored ? CGAffineTransformMakeScale(-1, 1) : CGAffineTransformIdentity;
if (!CGAffineTransformEqualToTransform(_scrollView.transform, transform)) {
_containerView.transform = transform;
_scrollView.transform = transform;
}
_scrollView.semanticContentAttribute = (rtl && !mirrored) ? UISemanticContentAttributeForceRightToLeft
: UISemanticContentAttributeForceLeftToRight;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, applied as suggested. The initWithFrame: comment now says left-to-right is the default and stays forced only while the view is mirrored.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flip assumes the scroll view is mirrored, which is now only true for horizontal views. For an RTL vertical view with content wider than the view, onScroll reports the mirrored x.

Suggested change
if ([self _isMirrored]) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, uses _isMirrored now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Suggested change
if ([self _isMirrored]) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, uses _isMirrored now.

A vertical ScrollView in RTL is no longer mirrored, so it now gets RTL
semantics (the vertical indicator stays on the left) and the x offset
conversions for onScroll and scrollTo run only for mirrored views.

Add RCTScrollViewComponentViewRTLTests for mirroring, semantics, the
scrollTo/onScroll x round trip and recycled views.
@ArekChr

ArekChr commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review and the repro, that made it easy to see.

1 and 2: I took your suggestions as they are. There is now a shared _isMirrored, both x conversions use it, and a vertical RTL scroll view gets UISemanticContentAttributeForceRightToLeft, so its indicator is back on the left. I also updated the comment in RCTEnhancedScrollView's initWithFrame:.

3: I went with the changelog option. Setting the initial offset would need extra logic for recycling and for content size changes, and a vertical scroll view whose content is wider than the view is rare, so I'd rather keep this change small. The changelog now says that such a view starts at the left edge in RTL.

I added RCTScrollViewComponentViewRTLTests to RNTesterUnitTests. It covers an RTL horizontal view staying mirrored, an RTL vertical view not being mirrored and getting RTL semantics, scrollTo and the reported x round-tripping in both, and a recycled view whose horizontal or layout direction changed.

I also ran your repro in RNTester: scrollTo({x: 0}) now shows x=0 to 300 and onScroll reports x=0.

@ArekChr
ArekChr requested a review from Abbondanzo November 27, 2026 12:18
@Abbondanzo

Copy link
Copy Markdown
Contributor

Thanks! Could you run the formatter again? I can import after that

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants